#ifndef _LOGIMPL__H_
#define _LOGIMPL__H_

#include "Poco/FileChannel.h"
#include "Poco/ConsoleChannel.h"
#include "Poco/SplitterChannel.h"
#include "Poco/Logger.h"
#include "Poco/AutoPtr.h"
#include "Poco/PatternFormatter.h"
#include "Poco/FormattingChannel.h"
#include "Poco/Mutex.h"

using Poco::FileChannel;
using Poco::ConsoleChannel;
using Poco::AutoPtr;
using Poco::SplitterChannel;
using Poco::Logger;
using Poco::FormattingChannel;
using Poco::PatternFormatter;
using Poco::Message;
#include <string>
#include <sstream>
using namespace std;
#include <cstdarg>

namespace YF
{
    #define LogBuffSize  1024*1024
    #define LogImplObj YF::LogImpl::getObj()
	class LogImpl
	{
	public:


		static LogImpl & getObj();

		//Logger  & getLogger();

		/*int     & getLogSwitch();*/

		void setLogSwitch(int logswitch);

		void setLogPath(const string & path);

		void setLogLevel(const string & level);

		void setRotion(const string & rotion);

		void setPattern(const string & pattern);

		void setConsoleSwitch(const int consoleswitch);

		void setFileSwitch(const int fileswitch);
		/*
		enum Priority
		{
			PRIO_FATAL = 1,   /// A fatal error. The application will most likely terminate. This is the highest priority.
			PRIO_CRITICAL,    /// A critical error. The application might not be able to continue running successfully.
			PRIO_ERROR,       /// An error. An operation did not complete successfully, but the application as a whole is not affected.
			PRIO_WARNING,     /// A warning. An operation completed with an unexpected result.
			PRIO_NOTICE,      /// A notice, which is an information with just a higher priority.
			PRIO_INFORMATION, /// An informational message, usually denoting the successful completion of an operation.
			PRIO_DEBUG,       /// A debugging message.
			PRIO_TRACE        /// A tracing message. This is the lowest priority.
		};
		*/
		void log(Message::Priority loglevel,const char * filename,const int fileline,char * fmt,...);

	private:
		static LogImpl _instance;
		LogImpl();
		AutoPtr<PatternFormatter>  pPF;
		AutoPtr<FileChannel> pFileChannel;
		AutoPtr<ConsoleChannel> pConsoleChannel;
		AutoPtr<SplitterChannel> pSplitterChannel;
		AutoPtr<FormattingChannel> pFF;  
		AutoPtr<FormattingChannel> pFC;
		Logger * _plogger;
		int  _logSwitch;
		bool _ispConsoleChannel;
		bool _ispFileChannel;
		char * _buff;
		Poco::FastMutex _m;
	};

} // namespace YF



#endif  // 
